package com.lzy.cloud.payment.service.impl;

import com.lzy.cloud.payment.dtos.payment.PayInfoDto;
import com.lzy.cloud.payment.entity.PayInfo;
import com.lzy.cloud.payment.mapper.PayInfoMapperExt;
import com.lzy.cloud.payment.service.PayInfoService;
import com.lzy.cloud.payment.utils.CommonsUtil;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PayInfoServiceImpl implements PayInfoService {
    @Autowired
    PayInfoMapperExt payInfoMapperExt;

    @Override
    public PayInfoDto queryPayInfoByOrderId(String orderId) {
        return payInfoMapperExt.queryPayInfoByOrderId(orderId);
    }

    @Override
    public int createPayInfo(PayInfoDto payInfoDto) {
        return payInfoMapperExt.insertSelective(DozerUtils.map(payInfoDto,PayInfo.class));
    }

    @Override
    public Boolean updatePayInfo(PayInfoDto payInfoDto) {
        int count = payInfoMapperExt.updateByPrimaryKeySelective(payInfoDto.converts());
        return !CommonsUtil.isEmpty(count);
    }
}
